﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.out_storage_detail
{
    public partial class Modify : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int out_storage_detail_Id = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(out_storage_detail_Id);
                }
            }
        }

        private void ShowInfo(int out_storage_detail_Id)
        {
            lcs.BLL.out_storage_detail bll = new lcs.BLL.out_storage_detail();
            lcs.Model.out_storage_detail model = bll.GetModel(out_storage_detail_Id);            
            this.txtreceive_address.Text = model.receive_address;
            this.txtreceive_userName.Text = model.receive_userName;
            this.txtreceive_userPhone.Text = model.receive_userPhone;
            this.txtreceive_time.Text = model.receive_time.ToString();
            //this.txtop_uid.Text = model.op_uid.ToString();
            this.txtremark.Text = model.remark;
            this.txtnums.Text = model.nums.ToString();
            this.txtjd.Text = model.jd.ToString();
            this.txtwd.Text = model.wd.ToString();

        }

        public void btnSave_Click(object sender, EventArgs e)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int out_storage_detail_Id = (Convert.ToInt32(Request.Params["id"]));
                string receive_address = this.txtreceive_address.Text;
                string receive_userName = this.txtreceive_userName.Text;
                string receive_userPhone = this.txtreceive_userPhone.Text;
                string out_name = this.txtout_name.Text;
                DateTime? receive_time = null;
                if (this.txtreceive_time.Text != "")
                    receive_time=DateTime.Parse(this.txtreceive_time.Text);
                //int op_uid = int.Parse(this.txtop_uid.Text);
                string remark = this.txtremark.Text;
                decimal nums = 0, jd = 0, wd = 0;
                //decimal.TryParse()
                decimal.TryParse(txtnums.Text.ToString(), out nums);
                decimal.TryParse(txtjd.Text.ToString(), out jd);
                decimal.TryParse(txtwd.Text.ToString(), out wd);
                lcs.Model.out_storage_detail model = new lcs.Model.out_storage_detail();
                model.out_storage_detail_Id = out_storage_detail_Id;                
                model.receive_address = receive_address;
                model.receive_userName = receive_userName;
                model.receive_userPhone = receive_userPhone;
                model.receive_time = receive_time;
                //model.op_uid = op_uid;
                model.remark = remark;
                model.nums = nums;
                model.jd = jd;
                model.wd = wd;
                model.out_name = out_name;
                lcs.BLL.out_storage_detail bll = new lcs.BLL.out_storage_detail();
                bll.UpdateEx(model);
                if (Request.Params["close"] != null )
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "a", "alert('保存成功！');window.opener=null;window.open('','_self');window.close();", true);
                    return;
                }
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");
            }

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
